﻿using UnityEngine;

namespace Vosvek.ProjectRogue
{

    /// <summary>
    /// Loot Drops are containers with colliders that have trigger enabled. 
    /// Standard containers (such as chests) are identical, except they have 
    /// trigger disabled.
    /// </summary>
    [RequireComponent(typeof(SpriteRenderer),
                      typeof(Collider2D))]
    public class Container : MonoBehaviour, IPlayerUsable
    {
        [SerializeField] Sprite playerUnseenSprite;
        [SerializeField] Sprite playerSeenSprite;
        [SerializeField] bool hasPlayerSeen;

        public Inventory Inventory;
        public bool HasPlayerSeen { get { return hasPlayerSeen; } }

        SpriteRenderer spriteRenderer;

        void Start()
        {
            spriteRenderer = GetComponent<SpriteRenderer>();
        }

        public void OnPlayerUse(Player player)
        {
            // TODO: Implement. Opens a Container SubView.
            throw new System.NotImplementedException();
        }

        void UpdateSprite()
        {
            if (spriteRenderer != null)
            {
                if (!hasPlayerSeen && playerUnseenSprite != null)
                {
                    spriteRenderer.sprite = playerUnseenSprite;
                }
                else if (playerSeenSprite != null)
                {
                    spriteRenderer.sprite = playerSeenSprite;
                }
            }
        }
    }

}
